SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.[DnnProduct_GetPortalSettings]
	@PortalID int,
	@CultureCode   nvarchar(50)
AS
	SELECT 
		SettingName,
		CASE WHEN LEFT(LOWER(dbo.DnnProduct_PortalSettings.SettingValue), 6) = 'fileid' 
			THEN
				(SELECT Folder + FileName  
					FROM dbo.DnnProduct_Files 
					WHERE 'fileid=' + convert(varchar,dbo.DnnProduct_Files.FileID) = dbo.DnnProduct_PortalSettings.SettingValue
				) 
			ELSE 
				dbo.DnnProduct_PortalSettings.SettingValue  
			END 
		AS SettingValue,
		dbo.DnnProduct_PortalSettings.CreatedByUserID,
		dbo.DnnProduct_PortalSettings.CreatedOnDate,
		dbo.DnnProduct_PortalSettings.LastModifiedByUserID,
		dbo.DnnProduct_PortalSettings.LastModifiedOnDate,
		dbo.DnnProduct_PortalSettings.CultureCode
	FROM dbo.DnnProduct_PortalSettings 
	WHERE  PortalID = @PortalID
	
GO
